#include"Library.h"
int functModifyBook(LibList* libList)
{
	printf("  修改书籍\n");
	printf("1.书名搜索\n");
	printf("2.ISBN码搜索\n");
	printf("0.退出\n");
	char choice[10];
	if(strcmp(choice,"0")==0)
		return 0;
	printf("请输入你要删除的方式:\n");
	scanf("%s", choice);
	if (choice[0] < '0' || choice[0]>'2' || strlen(choice) != 1)
	{
		printf("你是火星人吗?(任意键程序继续执行)\n");
		return -1;
	}
	char modifyName[MAX_BOOK_NAME + 1];
	scanf("%s", modifyName);
	bookNode* head = libList->head;
	while (head)
	{
		if ((strcmp(head->data.name, modifyName) == 0&&strcmp(choice,"1")==0)||(strcmp(head->data.ISBN, modifyName) == 0&&strcmp(choice,"2")==0));
		{
			printf("ISBN:%s\t书名:%s\t\t作者:%s\t\t价格:%.2f\t库存容量:%d\n", head->data.ISBN, head->data.name,
				head->data.auth, head->data.price, head->data.inventory);
			printf("你正在修改此书:\n");
			char sure[200];
			printf("是否要修改书名（Y/N)\n");
			scanf("%s", sure);
			if(strcmp(sure,"YES") == 0){
				printf("请输入修改后的书名:\n");
				scanf("%s", head->data.name);
			}
			else if(strcmp(sure,"NO") != 0){
				printf("输入错误");
				return -1;
			}
			printf("是否要修改ISBN码（Y/N)\n");
			scanf("%s", sure);
			if(strcmp(sure,"YES") == 0){
				printf("请输入修改后的ISBN码:\n");
				scanf("%s", head->data.ISBN);
			}
			else if(strcmp(sure,"NO") != 0){
				printf("输入错误");
				return -1;
			}
			printf("是否要修改作者（Y/N)\n");
			scanf("%s", sure);
			if(strcmp(sure,"YES") == 0){
				printf("请输入修改后的作者:\n");
				scanf("%s", head->data.auth);
			}
			else if(strcmp(sure,"NO") != 0){
				printf("输入错误");
				return -1;
			}
			printf("是否要修改库存容量（Y/N)\n");
			scanf("%s", sure);
			if(strcmp(sure,"YES") == 0){
				printf("请输入修改后的ISBN码:\n");
				scanf("%d", &head->data.inventory);
			}
			return 1;
		}
		head = head->next;
	}
	printf("没有找到该书\n");
	return -1;
}
